package b2.widget
{
	import b2.util.*;
	
	import flash.display.Sprite;
	import flash.text.*;

	public class LoadProgressBar extends Sprite
	{
		private var progressBar:ProgressBar;
		private var progressText:TextField;
		
		public function LoadProgressBar(percentage:Number = 0)
		{
			super();
			//进度条
			progressBar = new ProgressBar(CProgressBarFrame, CProgressBar, percentage);
			progressBar.x = 2;
			progressBar.y = 115;
			addChild(progressBar);
			//文字
			progressText = new TextField();
        	progressText.autoSize = TextFieldAutoSize.CENTER;
			progressText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x000000);
			progressText.selectable = false;
			progressText.text = "00%";
			progressText.x = (100 - progressText.width) / 2;
			progressText.y = progressBar.y;
			addChild(progressText);
			updateProgress(percentage);
		}
		
		public function updateProgress(percentage:Number):void
		{
			progressBar.percentage = percentage;
			var percentage100:int = percentage * 100;
			progressText.text = percentage100.toString() + "%";
		}
	}
}